package com.carnation._concurrent_collection;

import java.util.concurrent.ConcurrentHashMap;

/**
 * <p>
 * ConcurrentHashMap：不允许key、value为null，若为null则会报NPE，线程安全
 * </p>
 *
 * @author: Sunny
 * @date: 2021/2/2
 * @version: v1.0.0
 */
public class ConcurrentHashMapTest {

    private final ConcurrentHashMap<String, String> concurrentHashMap = new ConcurrentHashMap();

    public String get(String key) {
        return concurrentHashMap.get(key);
    }

    public void put(String key, String value) {
        concurrentHashMap.put(key, value);
    }

    public static void main(String[] args) {
        ConcurrentHashMapTest test = new ConcurrentHashMapTest();
        test.put("name", "zhangsan");
        System.out.println(test.get("name"));
    }

}
